package com.example.footballsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.footballsystem.entity.Tran;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Mapper
public interface TranMapper extends BaseMapper<Tran> {
    @Select("select * from tran")
    public List<Tran> selectAllTran();
    @Select("select * from tran where userID=#{userID}")
    public List<Tran> selectTodayTran(String userID);
    @Select("select * from tran where userID=#{account}")
    public List<Tran> selectTranByAccount(String account);
    @Select("select * from tran where isFinish=#{isFinish}&&userID=#{userID}")
    public List<Tran> selectUserFinishTran(String userID,Boolean isFinish);
    @Select("select * from tran where time=#{today}&isFinish=#{isFinish}&&userID=#{userID}")
    public List<Tran> selectTodayUserFinishTran(String userID,LocalDate today,  Boolean isFinish);
    @Insert("insert into tran value (#{userID},#{time},#{title},#{isFinish},#{selection},#{position})")
    public Boolean addTran(Tran tran);
    @Update("update tran set selection=1-selection where userID=#{userID}&&title=#{title}")
    public Boolean finishTran(String userID,String title);
    @Update("select * from tran where userID=#{userID}&&title=#{title}")
    public Tran getTran(String userID,String title);
    @Select("select COUNT(title) from tran group by userID")
    public List<Integer> getTranCount();
    @Select("select COUNT(*) from tran")
    public Integer count();
}
